//
//  MenuView.m
//  Reader
//
//  Created by mac on 16/12/21.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "MenuView.h"
#import "MenuTableViewCell.h"
#define RowNumber 2
#define RowHeight 30

@interface MenuView () <UITableViewDataSource, UITableViewDelegate>
{

}
@property (strong, nonatomic) UITableView *tableView;

@end

@implementation MenuView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return RowNumber;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MenuTableViewCell *cell = [[MenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    cell.textLabel.text = @"123456789";
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return RowHeight;
}


- (void)setTableViewFrame:(CGRect)frame
{
    self.tableView = [[UITableView alloc] initWithFrame:frame];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[MenuTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    [self addSubview:self.tableView];
}

+ (MenuView *)createMenuViewWithFrame:(CGRect)frame target:(UIViewController *)target
{
    MenuView *menuView = [[MenuView alloc] initWithFrame:frame];
    [menuView setTableViewFrame:menuView.frame];
    [target.view addSubview:menuView];
  
    return menuView;
}
@end
